<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
   
   <meta name="description" content="string operations">
    
    <meta name="author" content="John S. Urban" >
    <link rel="icon" href="../favicon.png">

    <title>strtok &ndash; M_strings</title>

    <link href="../css/bootstrap.min.css" rel="stylesheet">
    <link href="../css/pygments.css" rel="stylesheet">
    <link href="../css/font-awesome.min.css" rel="stylesheet">
    <link href="../css/local.css" rel="stylesheet">
    
    <link  href="../tipuesearch/tipuesearch.css" rel="stylesheet">
    
    

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    
    <script src="../js/jquery-2.1.3.min.js"></script>
    <script src="../js/svg-pan-zoom.min.js"></script>

  </head>

  <body>

    <!-- Fixed navbar -->
    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="../index.html">M_strings </a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
        
            <li class="dropdown hidden-xs visible-sm visible-md hidden-lg">
              <a href="#" class="dropdown-toggle"
              data-toggle="dropdown" role="button"
              aria-haspopup="true"
     aria-expanded="false">Contents <span class="caret"></span></a>
        <ul class="dropdown-menu">
          
              
            <li><a href="../lists/files.html">Source Files</a></li>
        
        
        
            <li><a href="../lists/modules.html">Modules</a></li>
        
            
                                
            <li><a href="../lists/procedures.html">Procedures</a></li>
        
               
            <li><a href="../lists/types.html">Derived Types</a></li>
        
        
            </ul>
            </li>


<li class="visible-xs hidden-sm visible-lg"><a href="../lists/files.html">Source Files</a></li>



<li class="visible-xs hidden-sm visible-lg"><a href="../lists/modules.html">Modules</a></li>



<li class="visible-xs hidden-sm visible-lg"><a href="../lists/procedures.html">Procedures</a></li>

                             
<li class="visible-xs hidden-sm visible-lg"><a href="../lists/types.html">Derived Types</a></li>


          </ul>
        
        <form action="../search.html" class="navbar-form navbar-right" role="search">
        <div class="form-group">
          <input type="text" class="form-control" placeholder="Search" name="q" id="tipue_search_input" autocomplete="off" required>
        </div>
<!--
        <button type="submit" class="btn btn-default">Submit</button>
-->
        </form>
        
        </div><!--/.nav-collapse -->
      </div>
    </nav>

    <div class="container">
    
  
  <div class="row">
    <h1>strtok
      <small>Function</small>
    
    </h1>
    
<div class="row">
  <div class="col-lg-12">
<div class="well well-sm">
  <ul class="list-inline" style="margin-bottom:0px;display:inline">
     
     
     
     
    
    
     <li><i class="fa fa-list-ol"></i>
       <a data-toggle="tooltip"
    data-placement="bottom" data-html="true"
    title=" 1.6% of total for procedures.">40 statements</a>
     </li> 
     
     
     
    <li><i class="fa fa-code"></i><a href="../src/M_strings.f90"> Source File</a></li>
     
     
  </ul>
  <ol class="breadcrumb in-well text-right">
  
    
     <li><a href='../sourcefile/m_strings.f90.html'>M_strings.f90</a></li>
    
     <li><a href='../module/m_strings.html'>M_strings</a></li>
    
  
     <li class="active">strtok</li>
  </ol>
</div>
</div>
</div>
<script>
  $(function () {
  $('[data-toggle="tooltip"]').tooltip()
  })
</script>

  </div>
  
  <div class="row">
    <div class="col-md-3 hidden-xs hidden-sm visible-md visible-lg">
    
<div id="sidebar">
  
<h3>Contents</h3>
 



<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#vars-0">Variables</a></h3></div>
  <div id="vars-0" class="panel-collapse collapse">
    <div class="list-group">
      
      <a class="list-group-item" href="../proc/strtok.html#variable-isource_len~2">isource_len</a>
      
    </div>
  </div>
</div>




















<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title">Source Code</h3></div>
  <div class="list-group">
    <a class="list-group-item" href="../proc/strtok.html#src">strtok</a>
  </div>
</div>



</div>

    </div>
    
    <div class="col-md-9" id='text'>
    <h2>
public function strtok(source_string, itoken, token_start, token_end, delimiters) result(strtok_status)
    
    
   
</h2>
    
  


    
    <h2 id="name">NAME</h2>
<div class="codehilite"><pre><span></span><code> strtok(3f) - [M_strings:TOKENS] Tokenize a string
 (LICENSE:PD)
</code></pre></div>

<h2 id="synopsis">SYNOPSIS</h2>
<p>function strtok(source_string,itoken,token_start,token_end,delimiters)
  result(strtok_status)</p>
<p>! returned value
   logical                      :: strtok_status
   ! string to tokenize
   character(len=<em>),intent(in)  :: source_string
   ! token count since started
   integer,intent(inout)        :: itoken
   ! beginning of token
   integer,intent(out)          :: token_start
   ! end of token
   integer,intent(inout)        :: token_end
   ! list of separator characters
   character(len=</em>),intent(in)  :: delimiters</p>
<h2 id="description">DESCRIPTION</h2>
<div class="codehilite"><pre><span></span><code> <span class="n">The</span> <span class="n">STRTOK</span><span class="p">(</span><span class="mi">3</span><span class="n">f</span><span class="p">)</span> <span class="n">function</span> <span class="n">is</span> <span class="n">used</span> <span class="n">to</span> <span class="n">isolate</span> <span class="n">sequential</span> <span class="n">tokens</span> <span class="n">in</span> <span class="n">a</span>
 <span class="n">string</span><span class="p">,</span> <span class="n">SOURCE_STRING</span><span class="p">.</span> <span class="n">These</span> <span class="n">tokens</span> <span class="n">are</span> <span class="n">delimited</span> <span class="n">in</span> <span class="n">the</span> <span class="n">string</span> <span class="n">by</span>
 <span class="n">at</span> <span class="n">least</span> <span class="n">one</span> <span class="n">of</span> <span class="n">the</span> <span class="n">characters</span> <span class="n">in</span> <span class="n">DELIMITERS</span><span class="p">.</span> <span class="n">The</span> <span class="n">first</span> <span class="n">time</span> <span class="n">that</span>
 <span class="n">STRTOK</span><span class="p">(</span><span class="mi">3</span><span class="n">f</span><span class="p">)</span> <span class="n">is</span> <span class="n">called</span><span class="p">,</span> <span class="n">ITOKEN</span> <span class="n">should</span> <span class="n">be</span> <span class="n">specified</span> <span class="n">as</span> <span class="n">zero</span><span class="p">.</span> <span class="n">Subsequent</span>
 <span class="n">calls</span><span class="p">,</span> <span class="n">wishing</span> <span class="n">to</span> <span class="n">obtain</span> <span class="n">further</span> <span class="n">tokens</span> <span class="n">from</span> <span class="n">the</span> <span class="n">same</span> <span class="n">string</span><span class="p">,</span>
 <span class="n">should</span> <span class="n">pass</span> <span class="n">back</span> <span class="n">in</span> <span class="n">TOKEN_END</span>  <span class="n">and</span> <span class="n">ITOKEN</span> <span class="n">until</span> <span class="n">the</span> <span class="n">function</span> <span class="n">result</span>
 <span class="n">returns</span> <span class="p">.</span><span class="n">false</span><span class="p">.</span>

 <span class="n">This</span> <span class="n">routine</span> <span class="n">assumes</span> <span class="n">no</span> <span class="n">other</span> <span class="n">calls</span> <span class="n">are</span> <span class="n">made</span> <span class="n">to</span> <span class="n">it</span> <span class="n">using</span> <span class="n">any</span> <span class="n">other</span>
 <span class="n">input</span> <span class="n">string</span> <span class="n">while</span> <span class="n">it</span> <span class="n">is</span> <span class="n">processing</span> <span class="n">an</span> <span class="n">input</span> <span class="n">line</span><span class="p">.</span>
</code></pre></div>

<h2 id="options">OPTIONS</h2>
<div class="codehilite"><pre><span></span><code> <span class="nv">source_string</span>  <span class="nv">input</span> <span class="nv">string</span> <span class="nv">to</span> <span class="nv">parse</span>
 <span class="nv">itoken</span>         <span class="nv">token</span> <span class="nv">count</span> <span class="nv">should</span> <span class="nv">be</span> <span class="nv">set</span> <span class="nv">to</span> <span class="nv">zero</span> <span class="k">for</span> <span class="nv">a</span> <span class="nv">new</span> <span class="nv">string</span>
 <span class="nv">delimiters</span>     <span class="nv">characters</span> <span class="nv">used</span> <span class="nv">to</span> <span class="nv">determine</span> <span class="nv">the</span> <span class="k">end</span> <span class="nv">of</span> <span class="nv">tokens</span>
</code></pre></div>

<h2 id="return">RETURN</h2>
<div class="codehilite"><pre><span></span><code> token_start    beginning position in SOURCE_STRING where token was found
 token_end      ending position in SOURCE_STRING where token was found
 strtok_status
</code></pre></div>

<h2 id="examples">EXAMPLES</h2>
<p>Sample program:</p>
<div class="codehilite"><pre><span></span><code><span class="w"> </span><span class="n">program</span><span class="w"> </span><span class="n">demo_strtok</span><span class="w"></span>
<span class="w"> </span><span class="k">use</span><span class="w"> </span><span class="n">M_strings</span><span class="p">,</span><span class="w"> </span><span class="k">only</span><span class="w"> </span><span class="err">:</span><span class="w"> </span><span class="n">strtok</span><span class="w"></span>
<span class="w"> </span><span class="n">implicit</span><span class="w"> </span><span class="k">none</span><span class="w"></span>
<span class="w"> </span><span class="k">character</span><span class="p">(</span><span class="nf">len</span><span class="o">=</span><span class="mi">264</span><span class="p">)</span><span class="w">          </span><span class="o">::</span><span class="w"> </span><span class="n">inline</span><span class="w"></span>
<span class="w"> </span><span class="k">character</span><span class="p">(</span><span class="nf">len</span><span class="o">=*</span><span class="p">),</span><span class="k">parameter</span><span class="w">  </span><span class="o">::</span><span class="w"> </span><span class="n">delimiters</span><span class="o">=</span><span class="s1">&#39; ;,&#39;</span><span class="w"></span>
<span class="w"> </span><span class="k">integer</span><span class="w">                     </span><span class="o">::</span><span class="w"> </span><span class="n">ios</span><span class="p">,</span><span class="w"> </span><span class="n">itoken</span><span class="p">,</span><span class="w"> </span><span class="n">istart</span><span class="p">,</span><span class="w"> </span><span class="n">iend</span><span class="w"></span>
<span class="w">    </span><span class="n">do</span><span class="w"> </span><span class="err">!</span><span class="w"> </span><span class="k">read</span><span class="w"> </span><span class="n">lines</span><span class="w"> </span><span class="k">from</span><span class="w"> </span><span class="n">stdin</span><span class="w"> </span><span class="n">until</span><span class="w"> </span><span class="k">end</span><span class="o">-</span><span class="k">of</span><span class="o">-</span><span class="k">file</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="n">error</span><span class="w"></span>
<span class="w">       </span><span class="k">read</span><span class="w"> </span><span class="p">(</span><span class="n">unit</span><span class="o">=*</span><span class="p">,</span><span class="n">fmt</span><span class="o">=</span><span class="ss">&quot;(a)&quot;</span><span class="p">,</span><span class="n">iostat</span><span class="o">=</span><span class="n">ios</span><span class="p">)</span><span class="w"> </span><span class="n">inline</span><span class="w"></span>
<span class="w">       </span><span class="k">if</span><span class="p">(</span><span class="n">ios</span><span class="p">.</span><span class="n">ne</span><span class="mf">.0</span><span class="p">)</span><span class="n">stop</span><span class="w"></span>
<span class="w">       </span><span class="err">!</span><span class="w"> </span><span class="n">must</span><span class="w"> </span><span class="k">set</span><span class="w"> </span><span class="n">ITOKEN</span><span class="o">=</span><span class="mi">0</span><span class="w"> </span><span class="k">before</span><span class="w"> </span><span class="n">looping</span><span class="w"> </span><span class="k">on</span><span class="w"> </span><span class="n">strtok</span><span class="p">(</span><span class="mi">3</span><span class="n">f</span><span class="p">)</span><span class="w"></span>
<span class="w">       </span><span class="err">!</span><span class="w"> </span><span class="k">on</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">string</span><span class="p">.</span><span class="w"></span>
<span class="w">       </span><span class="n">itoken</span><span class="o">=</span><span class="mi">0</span><span class="w"></span>
<span class="w">       </span><span class="n">do</span><span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="o">&amp;</span><span class="w"></span>
<span class="w">       </span><span class="o">&amp;</span><span class="p">(</span><span class="w"> </span><span class="n">strtok</span><span class="p">(</span><span class="n">inline</span><span class="p">,</span><span class="n">itoken</span><span class="p">,</span><span class="n">istart</span><span class="p">,</span><span class="n">iend</span><span class="p">,</span><span class="n">delimiters</span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"></span>
<span class="w">          </span><span class="k">print</span><span class="w"> </span><span class="o">*</span><span class="p">,</span><span class="w"> </span><span class="n">itoken</span><span class="p">,</span><span class="o">&amp;</span><span class="w"></span>
<span class="w">          </span><span class="o">&amp;</span><span class="w"> </span><span class="s1">&#39;TOKEN=[&#39;</span><span class="o">//</span><span class="p">(</span><span class="n">inline</span><span class="p">(</span><span class="nl">istart</span><span class="p">:</span><span class="n">iend</span><span class="p">))</span><span class="o">//</span><span class="s1">&#39;]&#39;</span><span class="p">,</span><span class="n">istart</span><span class="p">,</span><span class="n">iend</span><span class="w"></span>
<span class="w">       </span><span class="n">enddo</span><span class="w"></span>
<span class="w">    </span><span class="n">enddo</span><span class="w"></span>
<span class="w"> </span><span class="k">end</span><span class="w"> </span><span class="n">program</span><span class="w"> </span><span class="n">demo_strtok</span><span class="w"></span>

<span class="w"> </span><span class="n">sample</span><span class="w"> </span><span class="k">input</span><span class="w"> </span><span class="k">file</span><span class="w"></span>

<span class="w">  </span><span class="n">this</span><span class="w"> </span><span class="k">is</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="n">test</span><span class="w"> </span><span class="k">of</span><span class="w"> </span><span class="n">strtok</span><span class="p">;</span><span class="w"> </span><span class="nl">A</span><span class="p">:</span><span class="n">B</span><span class="w"> </span><span class="err">:</span><span class="p">;,</span><span class="n">C</span><span class="p">;;</span><span class="w"></span>

<span class="w"> </span><span class="n">sample</span><span class="w"> </span><span class="k">output</span><span class="w"> </span><span class="k">file</span><span class="w"></span>

<span class="w"> </span><span class="mi">1</span><span class="w">  </span><span class="n">TOKEN</span><span class="o">=[</span><span class="n">this</span><span class="o">]</span><span class="w">    </span><span class="mi">2</span><span class="w">   </span><span class="mi">5</span><span class="w"></span>
<span class="w"> </span><span class="mi">2</span><span class="w">  </span><span class="n">TOKEN</span><span class="o">=[</span><span class="n">is</span><span class="o">]</span><span class="w">      </span><span class="mi">7</span><span class="w">   </span><span class="mi">8</span><span class="w"></span>
<span class="w"> </span><span class="mi">3</span><span class="w">  </span><span class="n">TOKEN</span><span class="o">=[</span><span class="n">a</span><span class="o">]</span><span class="w">       </span><span class="mi">10</span><span class="w">  </span><span class="mi">10</span><span class="w"></span>
<span class="w"> </span><span class="mi">4</span><span class="w">  </span><span class="n">TOKEN</span><span class="o">=[</span><span class="n">test</span><span class="o">]</span><span class="w">    </span><span class="mi">12</span><span class="w">  </span><span class="mi">15</span><span class="w"></span>
<span class="w"> </span><span class="mi">5</span><span class="w">  </span><span class="n">TOKEN</span><span class="o">=[</span><span class="n">of</span><span class="o">]</span><span class="w">      </span><span class="mi">17</span><span class="w">  </span><span class="mi">18</span><span class="w"></span>
<span class="w"> </span><span class="mi">6</span><span class="w">  </span><span class="n">TOKEN</span><span class="o">=[</span><span class="n">strtok</span><span class="o">]</span><span class="w">  </span><span class="mi">20</span><span class="w">  </span><span class="mi">25</span><span class="w"></span>
<span class="w"> </span><span class="mi">7</span><span class="w">  </span><span class="n">TOKEN</span><span class="o">=[</span><span class="n">A:B</span><span class="o">]</span><span class="w">     </span><span class="mi">28</span><span class="w">  </span><span class="mi">30</span><span class="w"></span>
<span class="w"> </span><span class="mi">8</span><span class="w">  </span><span class="n">TOKEN</span><span class="o">=[</span><span class="n">:</span><span class="o">]</span><span class="w">       </span><span class="mi">32</span><span class="w">  </span><span class="mi">32</span><span class="w"></span>
<span class="w"> </span><span class="mi">9</span><span class="w">  </span><span class="n">TOKEN</span><span class="o">=[</span><span class="n">C</span><span class="o">]</span><span class="w">       </span><span class="mi">35</span><span class="w">  </span><span class="mi">35</span><span class="w"></span>
</code></pre></div>

<h2 id="author">AUTHOR</h2>
<div class="codehilite"><pre><span></span><code>John S. Urban
</code></pre></div>

<h2 id="license">LICENSE</h2>
<div class="codehilite"><pre><span></span><code>Public Domain
</code></pre></div>
    

    <h3>Arguments</h3>
    
      
<table class="table table-striped varlist">
<thead><tr><th>Type</th>
<th>Intent</th><th>Optional</th>
<th>Attributes</th><th></th><th>Name</th><th></th></thead>



<tbody>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-source_string~3"></span>character(len=*),</td>
  <td>intent(in)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>source_string</strong></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-itoken~2"></span>integer,</td>
  <td>intent(inout)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>itoken</strong></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-token_start~2"></span>integer,</td>
  <td>intent(out)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>token_start</strong></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-token_end~2"></span>integer,</td>
  <td>intent(inout)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>token_end</strong></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-delimiters~4"></span>character(len=*),</td>
  <td>intent(in)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>delimiters</strong></td><td></td>
  
</tr>

</tbody>
</table>

    
    
    
    
    
    
    
   <h3>Return Value <small><span class="anchor" id="variable-strtok_status"></span>logical
  </small></h3>
    
    
    
    
     
    <br>

    <section class="visible-xs visible-sm hidden-md">
      
<h3>Contents</h3>
 



<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#vars-1">Variables</a></h3></div>
  <div id="vars-1" class="panel-collapse collapse">
    <div class="list-group">
      
      <a class="list-group-item" href="../proc/strtok.html#variable-isource_len~2">isource_len</a>
      
    </div>
  </div>
</div>




















<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title">Source Code</h3></div>
  <div class="list-group">
    <a class="list-group-item" href="../proc/strtok.html#src">strtok</a>
  </div>
</div>



    </section>
    <br class="visible-xs visible-sm hidden-md">

    

    
    <section>    
      <h2>Variables</h2>
    
<table class="table table-striped varlist">
<thead><tr><th>Type</th><th>Visibility</th>

<th>Attributes</th><th></th><th>Name</th><th></th><th>Initial</th><th></th></thead>



<tbody>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-isource_len~2"></span>integer,</td>
  
  <td>public,</td>
  <td>save</td><td>::</td>
  <td><strong>isource_len</strong></td><td></td><td></td><td></td>
  
</tr>

</tbody>
</table>

    </section>
    <br>
    
    
    
    
    

    
    
    
    
    


    
    
    
    <section>
    <h2><span class="anchor" id="src"></span>Source Code</h2>
    <div class="highlight"><pre><span></span><span class="k">FUNCTION </span><span class="n">strtok</span><span class="p">(</span><span class="n">source_string</span><span class="p">,</span><span class="n">itoken</span><span class="p">,</span><span class="n">token_start</span><span class="p">,</span><span class="n">token_end</span><span class="p">,</span><span class="n">delimiters</span><span class="p">)</span> <span class="k">result</span><span class="p">(</span><span class="n">strtok_status</span><span class="p">)</span>
<span class="c">! JSU- 20151030</span>

<span class="c">! ident_14=&quot;@(#)M_strings::strtok(3f): Tokenize a string&quot;</span>

<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=*</span><span class="p">),</span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span>  <span class="kd">::</span> <span class="n">source_string</span>    <span class="c">! Source string to tokenize.</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=*</span><span class="p">),</span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span>  <span class="kd">::</span> <span class="n">delimiters</span>       <span class="c">! list of separator characters. May change between calls</span>
<span class="kt">integer</span><span class="p">,</span><span class="k">intent</span><span class="p">(</span><span class="n">inout</span><span class="p">)</span>        <span class="kd">::</span> <span class="n">itoken</span>           <span class="c">! token count since started</span>
<span class="kt">logical</span>                      <span class="kd">::</span> <span class="n">strtok_status</span>    <span class="c">! returned value</span>
<span class="kt">integer</span><span class="p">,</span><span class="k">intent</span><span class="p">(</span><span class="n">out</span><span class="p">)</span>          <span class="kd">::</span> <span class="n">token_start</span>      <span class="c">! beginning of token found if function result is .true.</span>
<span class="kt">integer</span><span class="p">,</span><span class="k">intent</span><span class="p">(</span><span class="n">inout</span><span class="p">)</span>        <span class="kd">::</span> <span class="n">token_end</span>        <span class="c">! end of token found if function result is .true.</span>
<span class="kt">integer</span><span class="p">,</span><span class="k">save</span>                 <span class="kd">::</span> <span class="n">isource_len</span>
<span class="c">!----------------------------------------------------------------------------------------------------------------------------</span>
<span class="c">!  calculate where token_start should start for this pass</span>
   <span class="k">if</span><span class="p">(</span><span class="n">itoken</span><span class="p">.</span><span class="n">le</span><span class="p">.</span><span class="mi">0</span><span class="p">)</span><span class="k">then</span>                           <span class="c">! this is assumed to be the first call</span>
      <span class="n">token_start</span><span class="o">=</span><span class="mi">1</span>
   <span class="k">else</span>                                          <span class="c">! increment start to previous end + 1</span>
      <span class="n">token_start</span><span class="o">=</span><span class="n">token_end</span><span class="o">+</span><span class="mi">1</span>
   <span class="k">endif</span>
<span class="c">!----------------------------------------------------------------------------------------------------------------------------</span>
   <span class="n">isource_len</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">source_string</span><span class="p">)</span>                <span class="c">! length of input string</span>
<span class="c">!----------------------------------------------------------------------------------------------------------------------------</span>
   <span class="k">if</span><span class="p">(</span><span class="n">token_start</span><span class="p">.</span><span class="n">gt</span><span class="p">.</span><span class="n">isource_len</span><span class="p">)</span><span class="k">then</span>            <span class="c">! user input error or at end of string</span>
      <span class="n">token_end</span><span class="o">=</span><span class="n">isource_len</span>                      <span class="c">! assume end of token is end of string until proven otherwise so it is set</span>
      <span class="n">strtok_status</span><span class="o">=</span><span class="p">.</span><span class="n">false</span><span class="p">.</span>
      <span class="k">return</span>
<span class="k">   endif</span>
<span class="c">!----------------------------------------------------------------------------------------------------------------------------</span>
   <span class="c">! find beginning of token</span>
   <span class="k">do while</span> <span class="p">(</span><span class="n">token_start</span> <span class="p">.</span><span class="n">le</span><span class="p">.</span> <span class="n">isource_len</span><span class="p">)</span>       <span class="c">! step thru each character to find next delimiter, if any</span>
      <span class="k">if</span><span class="p">(</span><span class="nb">index</span><span class="p">(</span><span class="n">delimiters</span><span class="p">,</span><span class="n">source_string</span><span class="p">(</span><span class="n">token_start</span><span class="p">:</span><span class="n">token_start</span><span class="p">))</span> <span class="p">.</span><span class="n">ne</span><span class="p">.</span> <span class="mi">0</span><span class="p">)</span> <span class="k">then</span>
<span class="k">         </span><span class="n">token_start</span> <span class="o">=</span> <span class="n">token_start</span> <span class="o">+</span> <span class="mi">1</span>
      <span class="k">else</span>
<span class="k">         exit</span>
<span class="k">      endif</span>
<span class="k">   enddo</span>
<span class="c">!----------------------------------------------------------------------------------------------------------------------------</span>
   <span class="n">token_end</span><span class="o">=</span><span class="n">token_start</span>
   <span class="k">do while</span> <span class="p">(</span><span class="n">token_end</span> <span class="p">.</span><span class="n">le</span><span class="p">.</span> <span class="n">isource_len</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>       <span class="c">! step thru each character to find next delimiter, if any</span>
      <span class="k">if</span><span class="p">(</span><span class="nb">index</span><span class="p">(</span><span class="n">delimiters</span><span class="p">,</span><span class="n">source_string</span><span class="p">(</span><span class="n">token_end</span><span class="o">+</span><span class="mi">1</span><span class="p">:</span><span class="n">token_end</span><span class="o">+</span><span class="mi">1</span><span class="p">))</span> <span class="p">.</span><span class="n">ne</span><span class="p">.</span> <span class="mi">0</span><span class="p">)</span> <span class="k">then</span>  <span class="c">! found a delimiter in next character</span>
         <span class="k">exit</span>
<span class="k">      endif</span>
<span class="k">      </span><span class="n">token_end</span> <span class="o">=</span> <span class="n">token_end</span> <span class="o">+</span> <span class="mi">1</span>
   <span class="k">enddo</span>
<span class="c">!----------------------------------------------------------------------------------------------------------------------------</span>
   <span class="k">if</span> <span class="p">(</span><span class="n">token_start</span> <span class="p">.</span><span class="n">gt</span><span class="p">.</span> <span class="n">isource_len</span><span class="p">)</span> <span class="k">then</span>        <span class="c">! determine if finished</span>
      <span class="n">strtok_status</span><span class="o">=</span><span class="p">.</span><span class="n">false</span><span class="p">.</span>                      <span class="c">! flag that input string has been completely processed</span>
   <span class="k">else</span>
<span class="k">      </span><span class="n">itoken</span><span class="o">=</span><span class="n">itoken</span><span class="o">+</span><span class="mi">1</span>                            <span class="c">! increment count of tokens found</span>
      <span class="n">strtok_status</span><span class="o">=</span><span class="p">.</span><span class="n">true</span><span class="p">.</span>                       <span class="c">! flag more tokens may remain</span>
   <span class="k">endif</span>
<span class="c">!----------------------------------------------------------------------------------------------------------------------------</span>
<span class="k">end function </span><span class="n">strtok</span>
</pre></div>

    </section>
    <br>
    
    
    </div>
  </div>


    <hr>    
    </div> <!-- /container -->
    <footer>
      <div class="container">
      <div class="row">
        <div class="col-xs-6 col-md-4"><p>&copy; 2022 
                                          </p></div>
        <div class="col-xs-6 col-md-4 col-md-push-4">
          <p class="text-right">
            Documentation generated by 
            <a href="https://github.com/cmacmackin/ford">FORD</a>
             on 2022-01-16 22:32  
          </p>
        </div>
        <div class="col-xs-12 col-md-4 col-md-pull-4"><p class="text-center"> M_strings was developed by John S. Urban</p></div>
      </div>
      <br>
      </div> <!-- /container -->    
    </footer>

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
<!--
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
-->
    <script src="../js/bootstrap.min.js"></script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="../js/ie10-viewport-bug-workaround.js"></script>

    <!-- MathJax JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        TeX: { extensions: ['AMSmath.js','AMSsymbols.js','noErrors.js','noUndefined.js'], equationNumbers: { autoNumber: 'AMS' } },
        jax: ['input/TeX','input/MathML','output/HTML-CSS'],
        extensions: ['tex2jax.js','mml2jax.js','MathMenu.js','MathZoom.js']
      });
    </script>
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    
    
    <script src="../tipuesearch/tipuesearch_content.js"></script>
    <script src="../tipuesearch/tipuesearch_set.js"></script>
    <script src="../tipuesearch/tipuesearch.js"></script>
    
    
  </body>
</html>